/**
 * Copyright ©2016-2020 northkingbpo Corporation, All Rights Reserved
 * http://www.northkingbpo.net/
 */
package com.north.king.profile.http.client.resttemplate.server.data;

import com.north.king.profile.http.client.resttemplate.domain.WorkItem;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * class info
 *
 * @author hujia
 * @date 2018/11/15 16:55
 */
@Service
public class CreateWorkItemData {

    /**
     * create workItem
     *
     * @param dataCount the number of the data
     * @param maxNumber the random max number
     * @return data-list
     */
    public List<WorkItem> workItemDataRandom(int dataCount, int maxNumber) {
        List<WorkItem> itemList = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < dataCount; ++i) {
            WorkItem item = new WorkItem();
            item.setId("id-test-" + i);
            item.setOrgBusiness("orgBusiness" + random.nextInt(maxNumber));
            item.setState(1);
            item.setPriority(10L);
            item.setTransitRefData5("data" + random.nextInt(maxNumber));
            item.setOrganizationalunit("unit" + random.nextInt(maxNumber));
            item.setBusiType("busiType" + random.nextInt(maxNumber));
            item.setWorkqueue("workqueue" + random.nextInt(maxNumber));
            item.setName(item.getOrgBusiness() + "-" + item.getWorkqueue() + "-" + item.getBusiType()
                    + "-" + item.getTransitRefData5());
            itemList.add(item);
        }
        return itemList;
    }

    public List<WorkItem> workItemDataDesignated(int dataCount, List<Integer> range) {
        List<WorkItem> itemList = new ArrayList<>();
        Random random = new Random();
        for (int i = 0; i < dataCount; ++i) {
            WorkItem item = new WorkItem();
            item.setId("id-test-" + i);
            item.setOrgBusiness("orgBusiness" + random.nextInt(range.get(0)));
            item.setState(1);
            item.setPriority(10L);
            item.setTransitRefData5("data" + random.nextInt(range.get(3)));
            item.setOrganizationalunit("unit" + i);
            item.setBusiType("busiType" + random.nextInt(range.get(2)));
            item.setWorkqueue("workqueue" + random.nextInt(range.get(1)));
            item.setName(item.getOrgBusiness() + "-" + item.getWorkqueue() + "-" + item.getBusiType()
                    + "-" + item.getTransitRefData5());
            itemList.add(item);
        }
        return itemList;
    }
}
